package org.jeecg.modules.wx.controller;

import com.alibaba.fastjson.JSONObject;
import liquibase.pro.packaged.S;
import org.jeecg.modules.system.entity.SysUser;
import org.jeecg.modules.wx.service.WxTokenService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.annotations.Param;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;
import java.util.Optional;

/**
 * @author
 * @ClassName WxController
 * @Description
 * @date 2024/4/2 16:50
 * @Version 1.0
 */
@Api(tags="微信小程序")
@RestController
@RequestMapping("/sys/wx")
@Slf4j
public class WxController {

    @Autowired
    private WxTokenService wxTokenService;

    @AutoLog(value = "微信小程序-获取用户信息")
    @ApiOperation(value="微信小程序-获取用户信息", notes="微信小程序-获取用户信息")
    @PostMapping("/getUserInfo")
    public JSONObject getUserInfo(@RequestBody Map<String,Object> params){
        return wxTokenService.getUserInfo(Optional.of(params.get("code")).map(Object::toString).orElse(""));
    }
}
